<!DOCTYPE html> 
<html>
<head> 
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Hello, World</title> 
<style type="text/css"> 
html{height:100%} 
body{height:100%;margin:0px;padding:0px} 
#allmap{height:100%} 
</style> 
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=yRZBuI9TF5yqBWRG1R5O7ohygWuuxA6V">
</script>
</head>  
<body> 
<div id="allmap"></div>
<script type="text/javascript">
// 使用浏览器定位当前城市
var geolocation = new BMap.Geolocation();
geolocation.getCurrentPosition(function(res){
  console.log(res); 
	if(this.getStatus() === window.BMAP_STATUS_SUCCESS){
		// var mk = new BMap.Marker(r.point);
		// map.addOverlay(mk);
		// map.panTo(r.point);
		alert('您的位置：'+res.address.city);
	}
	else {
		alert('failed'+this.getStatus());
	}        
});
</script> 
</body> 
</html>